import { useUserStore } from '@/stores/userStore';
import { getKeys } from '@/utils/getKeys';
import routerObj from '../config';
import { filterRoute } from './handleRoute';
import Layout from '@/layout';
export const routes = () => {
  const keys = getKeys(routerObj);
  // 将字符串分割成数组
  const arr = keys.map((item) => item.split('/'));
  // 最后的路由
  return filterRoute(arr);
};

export const asyncRoute = () => {
  const mainRouter = {
    path: '/',
    name: 'Index',
    redirect: '/dashboard',
    component: Layout,
    children: useUserStore().state.routes,
  };

  return mainRouter;
};
const genertorRoute = () => {
  let obj = [];
  obj = [
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/login'),
    },
  ];
  return obj;
};
export default genertorRoute;
